.TH "validation" 3 "Fri Aug 22 2014" "Version 0.8.0-158_trunk" "libnetconf" \" -*- nroff -*-
.ad l
.nh
.SH NAME
validation \- Data Validation 
\fCRFC 6241\fP defines NETCONF :validate capability intended to allow validation of the configuration data\&. This capability specifies new operation <validate> and adds <test-option> parameter to the <edit-config> operation\&.
.PP
On the client side, libnetconf allows to create <validate> RPC as well as to specify <test-option> of <edit-config> RPC\&.
.PP
On the server side, libnetconf performs data validation on \fBdatastore parts\fP that provides validators\&. libnetconf use Relax NG schema to validate syntax of the datastore content and Schematron to check semantics\&. Validators are loaded as a standalone files generated by \fIlnctool(1)\fP, which is part of libnetconf standard instalation\&.
.PP
libnetconf automatically searches for the validators during \fBncds_new()\fP and \fBncds_new_transapi()\fP calls\&. Validators are supposed to be placed in the same directory as data model provided to the mentioned function as its model_path parameter\&. Alternatively, validators can be connected with the datastore manually, using \fBncds_set_validation()\fP\&. This function also allows to switch off validation on a specific datastore part\&.
.PP
.SS "lnctool(1) Usage"
.PP
Complete list of \fIlnctool(1)\fP's options can be displayed using -h option: 
.PP
.nf
$ lnctool -h

.fi
.PP
.PP
Based on a YANG data model, \fIlnctool(1)\fP generates all necessary files needed by libnetconf\&. Basically, it generates YIN format of the data model required by \fBncds_new()\fP and \fBncds_new_transapi()\fP functions\&. If you use some extension models via \fBncds_add_model()\fP or \fBncds_add_models_path()\fP, you have to specify also these models as \fIlnctool(1)\fP's <augment models> parameter\&.
.PP
When used with -v option, \fIlnctool(1)\fP additionally generates Relax NG schemas and Schematron XSL stylesheet for validation\&. Here is an example for NACM data model (directory \&./models/ contains \fIietf-netconf-acm\&.yang\fP and \fIietf-yang-types\&.yang\fP models): 
.PP
.nf
$ lnctool -v -o ./nacm -p ../models/ ./models/ietf-netconf-acm.yang
### Converting YANG to YIN
         creating ./nacm/ietf-netconf-acm.yin
         creating ./nacm/ietf-yang-types.yin
### Done
### Generating Relax NG schemas for validation
         creating ./nacm/ietf-netconf-acm-data.rng
         creating ./nacm/ietf-netconf-acm-gdefs.rng
### Done
### Generating Schematron Stylesheet
         creating ./nacm/ietf-netconf-acm-schematron.xsl
### Done

.fi
.PP
.PP
Path to the output directory should be specified in the server source code to allow libnetconf to find imported data model (\fIietf-yang-types\&.yin\fP in this case)\&.
.PP
\fBNote:\fP
.RS 4
Return value checks are skipped in this example for simplicity\&. Do not copy-paste this example\&. Also note, that NACM is one of internal libnetconf datastores and it is not needed to add it manually by \fBncds_new()\fP\&. This is JUST a simple (stupid) example\&.
.RE
.PP
.PP
.PP
.nf
ds = ncds_new(NCDS_TYPE_FILE, "./nacm/ietf-netconf-acm.yin", NULL);
ncds_file_set_path(ds, ds_path);
ncds_init(ds);
ncds_add_models_path("./models/");
ncds_consolidate();
.fi
.PP
.PP
If the validators files are stored in the same directory as a basic data model (\fIietf-netconf-acm\&.yin\fP in this case), libnetconf automatically loads them during \fBncds_new()\fP or \fBncds_new_transapi()\fP calls\&. If you store the validators files somewhere else, \fBncds_set_validation()\fP function can be used to specify their location: 
.PP
.nf
ncds_set_validation(ds, 1, "./nacm/ietf-netconf-acm-data.rng", "./nacm/ietf-netconf-acm-schematron.xsl");

.fi
.PP
.PP
If validators files are not found or validation is switched off (via \fBncds_set_validation()\fP with enable parameter set to 0), validation is not performed on such datastore part\&. 
